import React from 'react';
import { postAccFeedbackInfoExecuteFeedbackInfo } from '../../../../financialApi'
import { Modal, Form, Input, Radio, message, Button } from 'antd';
const { TextArea } = Input;

/**
 * @description: 反馈确认-- 操作-- 确认按钮
 * @author: xiaoxujs
 * @updata: xiaoxujs（2021-09-07）创建
 */

const OKModule = ({ okModuleShow, setOkModuleShow, clickId, setClickId, listFun }) => {
    const [form] = Form.useForm();
    const { validateFields, resetFields } = form;
    const handleOk = () => {
        validateFields().then(values => {
            values.id = clickId;
            ; (async () => {
                const { code, msg } = await postAccFeedbackInfoExecuteFeedbackInfo(values);
                if (code === '20000') {
                    message.success('操作成功！');
                    setClickId(undefined);
                    resetFields();
                    listFun();
                    setOkModuleShow(false);
                } else {
                    message.error(msg);
                }
            })()
        })
    };

    const handleCancel = () => {
        setOkModuleShow(false);
    };
    return (
        <Modal
            title="确认"
            visible={okModuleShow}
            width={800}
            onCancel={handleCancel}
            bodyStyle={{ padding: '25px 63px' }}
            footer={[
                <Button style={{
                    width: '88px',
                    height: '34px',
                }} key="back" onClick={handleCancel}>
                    取消
                </Button>,
                <Button key="submit" style={{
                    width: '88px',
                    height: '34px',
                }} type="primary" onClick={handleOk}>
                    确定
                </Button>
            ]}
        >
            <Form form={form} >
                <Form.Item
                    label="通过"
                    name="stepEnum"
                    rules={[
                        {
                            required: true,
                            message: '请选择是否通过!',
                        },
                    ]}
                >
                    <Radio.Group>
                        <Radio value={true}>是</Radio>
                        <Radio value={false}>否</Radio>
                    </Radio.Group>
                </Form.Item>
                <Form.Item
                    label="备注"
                    name="description"
                    rules={[{ required: true, message: '请输入备注!' }]}
                    labelCol={{ span: 24, offset: 0 }}
                >
                    <TextArea showCount maxLength={100} />
                </Form.Item>
            </Form>
        </Modal>
    )
}

export default OKModule;